﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace S4Store.Domain
{
    public class Store
    {
        public Store()
        {
            Administrators = new HashSet<Administrator>();
            Sellers = new HashSet<Employee>();
        }
        public int Id { get; set; }
        public String Name { get; set; }
        public String Address { get; set; }
        public String Tel { get; set; }
        public String Contact { get; set; }
        public String Comment { get; set; }
        public String Code { get; set; }
        public int? PinPaiId { get; set; }

        public virtual ICollection<Administrator> Administrators { get; set; }
        public virtual ICollection<Employee> Sellers { get; set; }
        public virtual PinPai PinPai { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public IEnumerable<Employee> EnbleSellers
        {
            get
            {
                int enblestatus=(int)Status.NORMAL;
                return Sellers.Where(t => !t.IsClose && t.StatusValue == enblestatus);
            }
        }

        public IEnumerable<Employee> GetEnbleEmployee(EmployeeType type)
        {
            var employees = EnbleSellers;
            return employees.Where(t => (t.TypeValue & (int)type) == t.TypeValue);
        }
    }
}
